package com.show.dao.impl;

import com.show.dao.IUserDao;
import com.show.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

// 加入容器
@Repository
public class UserDaoImpl implements IUserDao {

    // 注入jdbcTemplate
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<User> findAll() {
        return jdbcTemplate.query("select * from user ",new BeanPropertyRowMapper<>(User.class));
    }
}
